<template>
  <common-page
    ref="commonPage"
    :bg-path="bgPath"
    :web-path="webPath"
    :columns="columns"
    :search-items="searchItems"
    :form-items="formItems"
  />
</template>
<script>
export default {
  data: function() {
    return {
      // ===== ===== ===== ===== 全局属性 ===== ===== ===== =====
      // 后台接口路径
      bgPath: 'health/health/health/medbox',
      // Web路径
      webPath: 'health/Health/Health/MedBox',
      // ===== ===== ===== ===== 页面配置 ===== ===== ===== =====
      // 搜索内容
      searchItems: [
        {
          rowIndex: 1,
          items: [
            {
              code: "userCode",
              name: "用户编码",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "userName",
              config: {
                edit: false
              },
              name: "用户名称",
              span: 6,
              type: "text"
            },
            {
              code: "medCode",
              name: "药品编码",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "medName",
              config: {
                edit: false
              },
              name: "药品名称",
              span: 6,
              type: "text"
            },
            {
              code: "medDosageCode",
              name: "药品剂型编码",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "medDosageName",
              name: "药品剂型名称",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "medFreqCode",
              name: "用药频次编码",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "medFreqName",
              name: "用药频次名称",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "positionSign",
              name: "药箱位置标识",
              span: 6,
              type: "select",
              config: {
                edit: false,
                options: [
                  { key: "1", value: "1号位" },
                  { key: "2", value: "2号位" }
                ]
              }
            }
          ]
        }
      ],
      // 列表内容
      columns: [
        {
          code: "userCode",
          name: "用户编码",
          span: 6,
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "userName",
          config: {
            edit: false
          },
          name: "用户名称",
          span: 6,
          type: "text"
        },
        {
          code: "medCode",
          name: "药品编码",
          span: 6,
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "medName",
          config: {
            edit: false
          },
          name: "药品名称",
          span: 6,
          type: "text"
        },
        {
          code: "medDosageCode",
          name: "药品剂型编码",
          span: 6,
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "medDosageName",
          name: "药品剂型名称",
          span: 6,
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "medFreqCode",
          name: "用药频次编码",
          span: 6,
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "medFreqName",
          name: "用药频次名称",
          span: 6,
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "doseNum",
          name: "用药剂量",
          span: 6,
          type: "number",
          config: {
            edit: false
          }
        },
        {
          code: "positionSign",
          name: "药箱位置标识",
          span: 6,
          type: "select",
          config: {
            edit: false,
            options: [
              { key: "1", value: "1号位" },
              { key: "2", value: "2号位" }
            ]
          }
        }
      ],
      // 增加/修改/详情 表单
      formItems: [
        {
          rowIndex: 1,
          items: [
            {
              code: "userCode",
              span: 6,
              name: "用户编码",
              type: "popup",
              config: {
                url: "base/user/user/user",
                filedList: [
                  { code: 'id', name: 'ID' },
                  { code: 'code', name: '编码' },
                  { code: 'name', name: '名称' }
                ],
                searcher: {},
                defaultValue: "",
                minLength: 0,
                maxLength: 20,
                disabled: false,
                rules: [
                  { required: true, message: '请选择用户', trigger: 'change' }
                ]
              },
              handleEvent: {
                /**
                 * 开窗组件被选择
                 * @param code
                 * @param row
                 */
                onPopupClick: (code, row) => {
                  this.$refs.commonPage.updateFormData(code, row.code)
                  this.$refs.commonPage.updateFormData("userName", row.name)
                  this.$refs.commonPage.updateFormData("userId", row.id)
                }
              }
            },
            {
              code: "userName",
              name: "用户名称",
              type: "text",
              span: 6,
              config: {
                edit: false,
                disabled: true
              }
            },
            {
              code: "medCode",
              span: 6,
              name: "药品编码",
              type: "popup",
              config: {
                url: "base/dictionary/medicinedic/materiel",
                filedList: [
                  { code: 'id', name: 'ID' },
                  { code: 'code', name: '编码' },
                  { code: 'name', name: '名称' }
                ],
                searcher: {},
                defaultValue: "",
                minLength: 0,
                maxLength: 20,
                disabled: false,
                require: true,
                rules: [
                  { required: true, message: '请选择药品', trigger: 'change' }
                ]
              },
              handleEvent: {
                /**
                 * 开窗组件被选择
                 * @param code
                 * @param row
                 */
                onPopupClick: (code, row) => {
                  this.$refs.commonPage.updateFormData(code, row.code)
                  this.$refs.commonPage.updateFormData("medName", row.name)
                  this.$refs.commonPage.updateFormData("medId", row.id)
                }
              }
            },
            {
              code: "medName",
              name: "药品名称",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "medDosageCode",
              span: 6,
              name: "药品剂型编码",
              type: "popup",
              config: {
                url: "base/dictionary/medicinedic/meddictionary",
                filedList: [
                  { code: 'id', name: 'ID' },
                  { code: 'code', name: '编码' },
                  { code: 'name', name: '名称' }
                ],
                searcher: {},
                defaultValue: "",
                minLength: 0,
                maxLength: 20,
                disabled: false,
                require: true,
                rules: [
                  { required: true, message: '请选择药品剂型', trigger: 'change' }
                ]
              },
              handleEvent: {
                /**
                 * 开窗组件被选择
                 * @param code
                 * @param row
                 */
                onPopupClick: (code, row) => {
                  this.$refs.commonPage.updateFormData(code, row.code)
                  this.$refs.commonPage.updateFormData("medDosageName", row.name)
                  this.$refs.commonPage.updateFormData("medDosageId", row.id)
                }
              }
            },
            {
              code: "medDosageName",
              name: "药品剂型名称",
              span: 6,
              type: "text",
              config: {
                edit: false,
                disabled: true
              }
            },
            {
              code: "medFreqCode",
              name: "用药频次编码",
              span: 6,
              type: "popup",
              config: {
                url: "base/dictionary/medicinedic/meddictionary",
                filedList: [
                  { code: 'id', name: 'ID' },
                  { code: 'code', name: '编码' },
                  { code: 'name', name: '名称' }
                ],
                searcher: {},
                defaultValue: "",
                minLength: 0,
                maxLength: 20,
                disabled: false,
                require: true,
                rules: [
                  { required: true, message: '请选择用药频次', trigger: 'change' }
                ]
              },
              handleEvent: {
                /**
                 * 开窗组件被选择
                 * @param code
                 * @param row
                 */
                onPopupClick: (code, row) => {
                  this.$refs.commonPage.updateFormData(code, row.code)
                  this.$refs.commonPage.updateFormData("medFreqName", row.name)
                  this.$refs.commonPage.updateFormData("medFreqId", row.id)
                }
              }
            },
            {
              code: "medFreqName",
              name: "用药频次名称",
              span: 6,
              type: "text",
              config: {
                edit: false,
                disabled: true
              }
            },
            {
              code: "doseNum",
              name: "用药剂量",
              span: 6,
              type: "number",
              config: {
                edit: false,
                precision: 2
              }
            },
            {
              code: "positionSign",
              name: "药箱位置标识",
              span: 6,
              type: "select",
              config: {
                edit: false,
                options: [
                  { key: "1", value: "1号位" },
                  { key: "2", value: "2号位" }
                ]
              }
            }
          ]
        }
      ]
    }
  }
}
</script>
